
import request, { mockRequest } from '@/utils/request';

export async function createEnterprise(data) {
    return request('/user/enterprise', {
        method: "POST",
        data: data
    });
}

export async function saveEnterprise(enterpriseId,data){
    return request(`/user/enterprise/${enterpriseId}`, {
        method: "POST",
        data: data
    });
}

export async function saveEnterpriseOwn(enterpriseId,data) {
    return request(`/user/enterprise/${enterpriseId}/updateOwner`, {
        method: "POST",
        data: data
    });
}

export async function setUserCurrentEnterprise(data) {
    return request('/user/enterprise-user/setCurrent', {
        method: "POST",
        data: data
    });
}

export async function listUserEnterprise() {
    return request('/user/enterprise-user/listUserEnterprise');
}

export async function getEnterpriseById(enterpriseId) {
    return request(`/user/enterprise/${enterpriseId}`);
}

//  ------------------- User -----------------------------
export async function getCurrentEnterprise() {
    return request('/user/enterprise-user/current',{
        method:"POST"
    });
}

export async function listEnterpriseUser(params) {
    return request(`/user/enterprise/user`,{
        params:params || {}
    });
}

export async function listUserBriefByEnterpriseId(params) {
    return request(`/user/enterprise/user/briefList`,{
        params:params
    });
}

export async function getUserEnterprise() {
    return request(`/user/enterprise/user/detail`);
}

export async function getInviteLink(data) {
    return request(`/user/enterprise/user/inviteLink`,{
        method:"POST",
        data:data
    });
}

export async function confirm(data) {
    return request(`/user/enterprise/user/confirm`,{
        method:"POST",
        data:data
    });
}

export async function confirmReject(data) {
    return request(`/user/enterprise/user/confirmReject`,{
        method:"POST",
        data:data
    });
}

export async function inviteUserByUsername(data) {
    return request(`/user/enterprise/user/inviteUserByUsername`,{
        method:"POST",
        data:data
    });
}

export async function getEnterpriseInviteDetail(enterpriseId) {
    return request(`/user/enterprise/user/inviteDetail/${enterpriseId}`);
}

export async function acceptInvite(enterpriseId) {
    return request(`/user/enterprise/user/acceptInvite/${enterpriseId}`,{
        method:"POST",
    });
}

export async function rejectInvite(enterpriseId){
    return request(`/user/enterprise/user/rejectInvite/${enterpriseId}`,{
        method:"POST",
    });
}

export async function deleteEnterpriseUser(userId) {
    return request(`/user/enterprise/user/${userId}`,{
        method:"DELETE",
    });
}
export async function updateEnterpriseUser(userId,data) {
    return request(`/user/enterprise/user/${userId}`,{
        method:"POST",
        data:data
    });
}

export async function acceptLinkInvite(data) {
    return request(`/user/enterprise-user/acceptInvite`,{
        method:"POST",
        data:{
            inviteCode:data
        }
    });
}

export async function getInviteDetail(data) {
    return request(`/user/enterprise-user/inviteDetail`,{
        params:{
            inviteCode:data
        }
    });
}
//  ------------------- Role -----------------------------
export async function listEnterpriseRoleTemplate() {
    return request(`/user/enterprise-role/enterprise/template`);
}

export async function listProjectRoleTemplate() {
    return request(`/user/enterprise-role/project/template`);
}

export async function listEnterpriseRole() {
    return request(`/user/enterprise/role/enterprise`);
}

export async function listProjectRole() {
    return request(`/user/enterprise/role/project`);
}

export async function saveEnterpriseRole(data) {
    return request(`/user/enterprise/role/${data.scope}`, {
        method: "POST",
        data: data
    });
}

export async function deleteEnterpriseRole(data) {
    return request(`/user/enterprise/role/${data.scope}/${data.id}`, {
        method: "DELETE",
        data: {}
    });
}

//  ------------------- Department -----------------------------

export async function saveEnterpriseDepartment(data) {
    return request(`/user/enterprise-department`, {
        method: "POST",
        data: data
    });
}

export async function deleteEnterpriseDepartment(data) {
    return request(`/user/enterprise-department/delete`, {
        method: "POST",
        data: data
    });
}

export async function getEnterpriseDepartment() {
    return request(`/user/enterprise/department`);
}


